Skip to content

feat(api): hot reload applies only the records that changed - #202

Merged
themightychris merged 3 commits into
developfrom
feat/incremental-reload
Oct 14, 2026
Merged

themightychris merged 3 commits into
developfrom
feat/incremental-reload

Conversation

@themightychris

Copy link
Copy Markdown
Member

Implements plans/incremental-reload.md. Stacked on #201.

After #200, hot reload holds the write lock while it rebuilds. Today that rebuild re-reads every sheet, which is the same full load that has run out of memory before. Now it applies only the records that changed.

How:

  • For each in-memory sheet, Sheet.diffFrom(<pre-reconcile commit>, { records: true }) lists what changed, and the old and new versions of each record are unindexed and indexed in the live state and the FTS index.
  • unindex* functions in state.ts are exact inverses of the loaders' index*, which is what makes the result equal to a full load.
  • It falls back to the full rebuild when any .gitsheets/ config changed or more than 5,000 records changed (a bulk import merge).
  • Records from diffFrom get the gitsheets-sheet/gitsheets-path annotations that queryAll() adds, because gitsheets' delete and upsert rely on them.
  • The webhook response and log report reloadMode.

The guard: incremental-reload.test.ts makes upstream adds, edits, renames and deletes across every in-memory sheet, then checks that the live state deep-equals a full load of the new tree, and checks search results. Breaking a single unindex* makes it fail; I checked. It also covers the config-change fallback and deleting an incrementally loaded record through gitsheets.

Spec: storage.md → Hot reload: incremental by default, the full-rebuild fallback, and the requirement that both produce the same result.

Validation: type-check, lint and the full suite pass (501 API tests). Sandbox timing and heap measurements are left for after a release.

🤖 Generated with Claude Code

themightychris and others added 3 commits October 13, 2026 22:26
A full rebuild re-reads every sheet while holding the write lock, and
the full import has OOM'd that path before. Apply the commit diff
instead, with a full-rebuild fallback for config changes and bulk
merges, and require the result to equal a full rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hot reload re-read every sheet while holding the write lock. Now it
diffs each in-memory sheet from the pre-reconcile commit (gitsheets
Sheet.diffFrom) and unindexes/indexes just the changed records, with
unindex* written as the exact inverse of index*. Falls back to the full
rebuild when a sheet config changed or more than 5,000 records moved.

The equivalence test checks the incrementally updated state deep-equals
a full load across adds, edits, renames and deletes; breaking a single
unindex function fails it. The webhook response reports reloadMode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@themightychris
themightychris force-pushed the fix/slug-rename-attachments branch from 0bbf1c8 to de0fa36 Compare October 14, 2026 02:26
@themightychris
themightychris force-pushed the feat/incremental-reload branch from bdd9621 to 044fe1f Compare October 14, 2026 02:26
Base automatically changed from fix/slug-rename-attachments to develop October 14, 2026 02:40
@themightychris
themightychris merged commit c7ae2f5 into develop Oct 14, 2026
1 of 2 checks passed
@themightychris
themightychris deleted the feat/incremental-reload branch October 14, 2026 02:40
@themightychris themightychris mentioned this pull request Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant